<!-- include tpl=head_lay nopadding=true -->
<link rel="stylesheet" type="text/css" href="js/webuploader/webuploader.css" charset="utf-8" />
<script type="text/javascript" src="js/webuploader/webuploader.min.js" charset="utf-8"></script>
<script type="text/javascript" src="js/webuploader/admin.upload.js" charset="utf-8"></script>
<script type="text/javascript">
var obj_upload = {};
$(document).ready(function(){
	cate_change();
});
function cate_change()
{
	val = $("#add_cate_id").val();
	if(!val){
		$.dialog.alert('请选择要存储的目标分类');
		return false;
	}
	var data = $("#add_cate_id option[value="+val+"]").attr('data');
	var catename = $("#add_cate_id option[value="+val+"]").attr('catename');
	obj_upload = new $.admin_upload({
		"multiple"	: 'false',
		"id" : "upload",
		'pick':{'id':'#upload_picker','multiple':false},
		'resize':false,
		"swf" : "js/webuploader/uploader.swf",
		"server": "{url ctrl=upload func=save/}",
		"filetypes" : "{$rs.ext}",
		'accept' : {'title':catename,'extensions':data},
		"formData" :{'{func session_name}':'{func session_id}','cateid':val},
		'fileVal':'upfile',
		'auto':true,
		"success":function(){
			$.dialog.alert('附件上传成功',function(){
				$.phpok.reload();
			});
		}
	});
}
function select_file(file_id)
{
	var url =get_plugin_url('phpexcel',"import_user_setting","file="+file_id);
	$.phpok.go(url);
}
</script>
<div class="layui-card">
	<div class="layui-card-header">
		Excel 文件上传，仅支持 xls 和 xlsx
	</div>
	<div class="layui-card-body">
		<div class="layui-form-item layui-form">
			<div class="layui-input-block">
				<table>
				<tr>
					<td>
						<select id="add_cate_id" onchange="cate_change()" lay-ignore>
							<!-- loop from=$catelist key=$key value=$value -->
							<option value="{$value.id}"{if $value.is_default} selected{/if} data="{$value.filetypes}" catename="{$value.title}">
							{$value.title}<!-- if $value.filetypes --> / {lang支持上传格式：}{$value.filetypes}<!-- /if --></option>
							<!-- /loop -->
						</select>
					</td>
					<td>
						<div style="margin-top:4px;"><div id="upload_picker"></div></div>
					</td>
				</tr>
				</table>
			</div>
			<div class="layui-input-block mtop" style="margin-left:10px;min-height:20px;"><div class="content" id="upload_progress"></div></div>
		</div>

		<table class="layui-table">
		<thead>
		<tr>
			<th>附件名称</th>
			<th>上传时间</th>
			<th>操作</th>
		</tr>
		</thead>
		<!-- loop from=$rslist key=$key value=$value id=$tmpid -->
		<tr>
			<td>{$value.title}</td>
			<td>{func date "Y-m-d H:i:s" $value.addtime}</td>
			<td><input type="button" value="选择" onclick="select_file('{$value.id}')" class="layui-btn layui-btn-sm" /></td>
		</tr>
		<!-- /loop -->
		</table>
	</div>
</div>

<!-- include tpl=foot_lay is_open=true -->